/**
 * @class RefApp.models.OrderForm
 * @extends Ext.data.Model
 * The Form Model
 * Describes form items and their validations
 */

RefApp.models.OrderForm = Ext.regModel('OrderForm', {
    fields: [
        {
            name: 'name',
            type: 'string'
        }, {
            name: 'surname',
            type: 'string'
        }, {
            name: 'email',
            type: 'string'
        }, {
            name: 'phone',
            type: 'string'
        }, {
            name: 'street',
            type: 'string'
        }, {
            name: 'city',
            type: 'string'
        }, {
            name: 'house',
            type: 'string'
        }, {
            name: 'apartment',
            type: 'string'
        }
    ],

    validations: [
        {
            type: 'presence',
            name: 'name',
        }, {
            type: 'presence',
            name: 'surname'
        }, {
            type: 'presence',
            name: 'street'
        }, {
            type: 'presence',
            name: 'house'
        }, {
            type: 'presence',
            name: 'city'
        }, {
            type: 'format',
            name: 'phone',
            matcher: /^([0-9]{9})$/
            //message: ' - błędny numer telefonu'
        }, {
            type: 'format',
            name: 'email',
            matcher: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
            //message: ' - zły format e-maila'
        }
    ],
    proxy: {
        type: 'localstorage',
        id  : 'orderFormStorage'
    }
});